import type { RouteRecordRaw } from "vue-router";
/**
 * 路由meta对象参数说明
 * meta: {
 *      title:          菜单栏及 tagsView 栏、菜单搜索名称（国际化）
 *      hidden：        是否隐藏此路由
 *      icon：          菜单、tagsView 图标，阿里：加 `iconfont xxx`，fontawesome：加 `fa xxx`
 * }
 */

const Layout = () => import("@/layout/index.vue");
const Storage = () => import("@/views/storage/index.vue");
const Hospital = () => import("@/views/hospital/index.vue");

/**
 * 静态路由（默认路由）
 * 没有登录能够访问（不需要权限就能访问）路由表
 */
export const staticRoutes: Array<RouteRecordRaw> = [
  {
    path: "/login",
    name: "Login",
    component: () => import("@/views/login/index.vue"),
    meta: {
      hidden: true,
    },
  },

  {
    path: "/404",
    name: "404",
    component: () => import("@/views/error/404.vue"),
    meta: {
      hidden: true,
    },
  },

  {
    path: "/",
    component: () => import("@/layout/index.vue"),
    redirect: "/home",
    children: [
      {
        path: "home",
        name: "Home",
        component: () => import("@/views/home/index.vue"),
        // 1. 决定左侧菜单显示什么内容 2. 决定网站的title
        meta: {
          title: "首页",
          icon: "ele-HomeFilled",
        },
      },
    ],
  },

  // 基础数据模块
  {
    path: "/storage/base",
    component: Layout,
    redirect: "/storage/base/dict/list",
    name: "Base",
    meta: {
      title: "基础数据",
      icon: "ele-Menu",
    },
    children: [
      {
        path: "dict/list",
        name: "Dict",
        component: Storage,
        meta: { title: "数据字典", icon: "ele-Grid" },
      },
      {
        path: "shipperInfo/list",
        name: "ShipperInfo",
        component: Storage,
        meta: { title: "货主管理", icon: "ele-Grid" },
      },
      {
        path: "goodsType/list",
        name: "GoodsType",
        component: Storage,
        meta: { title: "货品分类", icon: "ele-Grid" },
      },
      {
        path: "goodsInfo/list",
        name: "GoodsInfo",
        component: Storage,
        meta: { title: "货品管理", icon: "ele-Grid" },
      },
    ],
  },

  // 储位管理
  {
    path: "/storage/ware",
    component: Layout,
    redirect: "/storage/ware/warehouseInfo/list",
    name: "Ware",
    meta: {
      title: "储位管理",
      icon: "ele-Menu",
    },
    children: [
      {
        path: "warehouseInfo/list",
        name: "WarehouseInfo",
        component: Storage,
        meta: { title: "仓库管理", icon: "ele-Grid" },
      },
      {
        path: "storeareaInfo/list",
        name: "StoreareaInfo",
        component: Storage,
        meta: { title: "库区管理", icon: "ele-Grid" },
      },
      {
        path: "storeshelfInfo/list",
        name: "StoreshelfInfo",
        component: Storage,
        meta: { title: "货架管理", icon: "ele-Grid" },
      },
      {
        path: "storehouseInfo/list",
        name: "StorehouseInfo",
        component: Storage,
        meta: { title: "库位管理", icon: "ele-Grid" },
      },
    ],
  },

  // 入库管理
  {
    path: "/storage/inbound",
    component: Layout,
    redirect: "/storage/inbound/inOrder/list",
    name: "Inbound",
    meta: {
      title: "入库管理",
      icon: "ele-Menu",
    },
    children: [
      {
        path: "inOrder/list",
        name: "InOrder",
        component: Storage,
        meta: { title: "入库预约", icon: "ele-Grid" },
      },
      {
        path: "inOrder/show/:id",
        name: "InOrderShow",
        component: Storage,
        meta: { title: "入库详情", hidden: true },
      },
      {
        path: "inApproveTask/list",
        name: "InApproveTask",
        component: Storage,
        meta: { title: "入库审批", icon: "ele-Grid" },
      },
      {
        path: "inReceivingTask/list",
        name: "InReceivingTask",
        component: Storage,
        meta: { title: "收货任务", icon: "ele-Grid" },
      },
      {
        path: "inPutawayTask/list",
        name: "InPutawayTask",
        component: Storage,
        meta: { title: "上架任务", icon: "ele-Grid" },
      },
    ],
  },

  // 库内管理
  {
    path: "/storage/inventoryInfo",
    component: Layout,
    redirect: "/storage/inventoryInfo/list",
    name: "Inventory",
    meta: {
      title: "库内管理",
      icon: "ele-Menu",
    },
    children: [
      {
        path: "list",
        name: "InventoryInfo",
        component: Storage,
        meta: { title: "实时库存", icon: "ele-Grid" },
      },
      {
        path: "invCounting/list",
        name: "InvCounting",
        component: Storage,
        meta: { title: "库内盘点", icon: "ele-Grid" },
      },
      {
        path: "show/:id",
        name: "InvCountingShow",
        component: Storage,
        meta: {
          title: "盘点单详情",
          hidden: true,
          icon: "ele-Grid",
        },
      },
      {
        path: "invCountingTask/list",
        name: "InvCountingTask",
        component: Storage,
        meta: { title: "盘点任务", icon: "ele-Grid" },
      },
      {
        path: "invMove/list",
        name: "InvMove",
        component: Storage,
        meta: { title: "移库管理", icon: "ele-Grid" },
      },
      {
        path: "invMoveTask/list",
        name: "InvMoveTask",
        component: Storage,
        meta: { title: "移库任务", icon: "ele-Grid" },
      },
      {
        path: "invMoveTask/show/:id",
        name: "InvMoveTaskShow",
        component: Storage,
        meta: {
          title: "移库任务详情",
          hidden: true,
          icon: "ele-Grid",
        },
      },
      {
        path: "invMove/show/:id",
        name: "InvMoveShow",
        component: Storage,
        meta: { title: "移库详情", hidden: true, icon: "ele-Grid" },
      },
    ],
  },

  // 出库管理
  {
    path: "/storage/outbound",
    component: Layout,
    redirect: "/storage/outbound/inOrder/list",
    name: "Outbound",
    meta: {
      title: "出库管理",
      icon: "ele-Menu",
    },
    children: [
      {
        path: "outOrder/list",
        name: "OutOrder",
        component: Storage,
        meta: { title: "出库单管理", icon: "ele-Grid" },
      },
      {
        path: "outOrder/show/:id",
        name: "OutOrderShow",
        component: Storage,
        meta: {
          title: "出库单详情",
          hidden: true,
          icon: "ele-Grid",
        },
      },
      {
        path: "outPickingTask/list",
        name: "OutPickingTask",
        component: Storage,
        meta: { title: "拣货任务", icon: "ele-Grid" },
      },
      {
        path: "outDeliverTask/list",
        name: "OutDeliverTask",
        component: Storage,
        meta: { title: "发货任务", icon: "ele-Grid" },
      },
    ],
  },

  // 配置
  {
    path: "/storage/config",
    component: Layout,
    redirect: "/storage/config/wareConfig/list",
    name: "Config",
    meta: {
      title: "配置管理",
      icon: "ele-Menu",
    },
    children: [
      {
        path: "wareConfig/list",
        name: "WareConfig",
        component: Storage,
        meta: { title: "配置列表", icon: "ele-Menu" },
      },
    ],
  },

  // 医院
  {
    path: "/hospital",
    meta: { icon: "ele-Menu", title: "医院管理" },
    component: Layout,
    children: [
      {
        path: "hospitalset",
        name: "HospitalSet",
        meta: { title: "医院设置" },
        component: Hospital,
      },
      {
        path: "hospitalset/add",
        meta: { title: "添加医院", hidden: true },
        name: "HospitalSetAdd",
        component: Hospital,
      },
      {
        path: "hospitalset/update/:id",
        meta: { title: "修改医院", hidden: true },
        name: "HospitalSetUpdate",
        component: Hospital,
      },
      {
        path: "hospitallist",
        meta: { title: "医院列表" },
        name: "HospitalList",
        component: Hospital,
      },
      {
        path: "hospitallist/schedule",
        meta: { title: "医院排班", hidden: true },
        name: "HospitalListSchedule",
        component: Hospital,
      },
      {
        path: "hospitallist/show/:id",
        meta: { title: "医院详情", hidden: true },
        name: "HospitalListShow",
        component: Hospital,
      },
    ],
  },
];

const Product = () => import("@/views/product/index.vue");

/**
 * 定义动态路由
 * 需要登录并且拥有访问权限才能访问的路由表
 */
export const allAsyncRoutes: Array<RouteRecordRaw> = [
  /*
    如果只有一个子路由，左侧菜单会显示子路由meta.title
    如果有多个子路由，左侧菜单会显示父路由meta.title
  */
  {
    path: "/product",
    component: Layout,
    redirect: "/product/trademark/list",
    name: "Product",
    meta: {
      title: "商品管理",
      // https://element-plus.org/zh-CN/component/icon.html#icon-collection
      icon: "ele-ShoppingBag",
    },
    children: [
      {
        path: "/product/trademark/list", // 如果路径不以 / 开头，路径就会拼接上父路由路径
        name: "Trademark",
        component: Product,
        meta: {
          title: "品牌管理", // 1. 决定左侧菜单显示什么内容 2. 决定网站的title
        },
      },
      // {
      //   path: "category/list",
      //   name: "Category",
      //   component: Product,
      //   meta: {
      //     title: "分类管理",
      //   },
      // },
      {
        path: "attr/list",
        name: "Attr",
        component: Product,
        meta: {
          title: "平台属性管理",
        },
      },
      {
        path: "spu/list",
        name: "Spu",
        component: Product,
        meta: {
          title: "SPU管理",
        },
      },
      {
        path: "sku/list",
        name: "Sku",
        component: Product,
        meta: {
          title: "SKU管理",
        },
      },
    ],
  },

  {
    path: "/acl",
    component: Layout,
    redirect: "/acl/user/list",
    name: "Acl",
    meta: {
      title: "权限管理",
      icon: "ele-Setting",
    },
    children: [
      {
        path: "user/list",
        name: "User",
        component: () => import("@/views/acl/user/index.vue"),
        meta: {
          title: "用户管理",
        },
      },
      {
        path: "role/list",
        name: "Role",
        component: () => import("@/views/acl/role/index.vue"),
        meta: {
          title: "角色管理",
        },
      },
      {
        path: "role/auth",
        name: "RoleAuth",
        component: () => import("@/views/acl/role/components/RoleAuth.vue"),
        meta: {
          title: "角色管理",
          hidden: true,
          activeMenu: "/acl/role/list",
        },
      },
      {
        path: "permission/list",
        name: "Permission",
        component: () => import("@/views/acl/permission/index.vue"),
        meta: {
          title: "菜单管理",
        },
      },
    ],
  },
];

/**
 * 任意路由表
 * 动态添加路由，任意路由表要最后添加才能生效
 */
export const anyRoutes = [
  /* 匹配任意的路由 必须最后注册 */
  {
    path: "/:pathMatch(.*)",
    name: "Any",
    redirect: "/404",
    meta: {
      hidden: true,
    },
  },
];
